<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="layui/css/layui.css" rel="stylesheet">
    <script src="layui/layui.js"></script>
    <script type="text/javascript" src="layui/tableSelect.js"></script>
</head>
<body>
    <script>
        layui.use(['table', 'form', 'tableSelect'], function () {
            var $ = layui.jquery,
                tableSelect = layui.tableSelect;
            //新增托管人下拉表格
            tableSelect.render({
                elem: '#cashId',
                checkedKey: 'cashId',
                table: {
                    url: 'selectCash',
                    cols: [
                        [
                            {type: 'checkbox', fixed: 'left'},
                            {field: 'cashId', title: '现金账号ID', sort: true, fixed: 'left'}
                            , {field: 'bankId', title: '银行卡号'}
                            , {field: 'accountName', title: '账户名称', sort: true}
                        ]]
                },
                done: function (elem, data) {
                    var NEWJSON = [];
                    layui.each(data.data, function (index, item) {
                        NEWJSON.push(item.accountName)
                        $("#hiddenCashId").val(item.cashName)
                    });
                    elem.val(NEWJSON.join(","))
                }
            });
        });
    </script>
<form id="addCash" lay-filter="addCash"
      class="layui-form layui-form-pane"
      style="margin: 30px auto; display: inline-block;" >
    <div class="layui-form-item" style="text-align: center;">
        <input type="hidden" lay-verify="required"
               autocomplete="off" placeholder="资金调拨Id" class="layui-input" id="fundsAllotId" name="fundsAllotId">
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">现金账户</label>
        <div class="layui-input-inline">
            <input type="text" lay-verify="required"
                   autocomplete="off" placeholder="现金账户" class="layui-input" id="cashId" name="cashId">
            <input type="hidden" name="cashName" id="hiddenCashId">
        </div>
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">调拨日期</label>
        <div class="layui-input-inline">
            <input type="date" lay-verify="required"
                   autocomplete="off" placeholder="调拨日期" class="layui-input" id="allotTime" name="allotTime">
        </div>
    </div>
    <div class="layui-form-item" style="text-align: center;">
        <label class="layui-form-label layui-bg-gray" style=" width: 140px;margin-left: 35px;">调拨类型</label>
        <div class="layui-input-inline">
            <select id="allotType" name="allotType">
                <option placeholder="请选择调拨类型" value=""></option>
                <option  value="1">存款利息</option>
                <option  value="2">申购赎回清算款</option>
                <option  value="3">买卖交易清算款</option>
                <option  value="4">债券利息</option>
                <option  value="5">存款业务</option>
                <option  value="6">俩费</option>
            </select>
        </div>
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">调拨方向</label>
        <div class="layui-input-inline">
            <select id="allotDirection" name="allotDirection">
                <option placeholder="请选择调拨方向" value=""></option>
                <option value="1">流入</option>
                <option value="-1">流出</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item" style="text-align: center;">
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">调拨金额</label>
        <div class="layui-input-inline">
                <input type="number" lay-verify="required"
                       autocomplete="off" placeholder="调拨金额" class="layui-input" id="allotMoney" name="allotMoney">
        </div>
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">业务编号</label>
        <div class="layui-input-inline">
            <input type="text" lay-verify="required"
                   autocomplete="off" placeholder="业务编号" class="layui-input" id="businessId" name="businessId">

        </div>
    </div>
    <div class="layui-form-item" style="text-align: center;">
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">业务日期</label>
        <div class="layui-input-inline">
            <input type="date" lay-verify="required"
                   autocomplete="off" placeholder="业务日期" class="layui-input" id="businessTime" name="businessTime">
        </div>

    </div>
    <div class="layui-inline layui-show-xs-block">
        <label class="layui-form-label layui-bg-gray"
               style=" width: 130px; height: 100px; line-height: 81px; margin-left: 100px">备注</label>
        <div class="layui-inline layui-show-xs-block">
                <textarea name="allotRemark" required placeholder="备注" class="layui-textarea"
                          style="width: 467px"></textarea>
        </div>
    </div>
    <div class="layui-form-item" style="position: absolute;left: 28%; bottom: 20px">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="addCash"><i class="layui-icon">&#x1005;</i>修改</button>
            <button type="reset" class="layui-btn layui-btn-primary"> <i class="layui-icon">&#x1006;</i>取消</button>
        </div>
    </div>
</form>

<script type="text/javascript">
    layui.use('form',function (){
        var form = layui.form;
        var $ = layui.jquery;

        form.on('submit(addCash)',function(obj){
            console.log(obj.field);
            $.ajax({
                url:"updateFundsAllots",
                type:"get",
                data:obj.field,
                dataType:"text",
                contentType:"application/x-www-form-urlencoded",//内容类型  form 表单的
                success:function(msg){
                    if(msg===1){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    })
</script>
</body>
</html>